﻿namespace OboutInc.Splitter2
{
    using System;
    using System.ComponentModel;
    using System.Drawing.Design;
    using System.Web.UI;
    using System.Web.UI.Design;

    [PersistChildren(true), ToolboxItem(false), ParseChildren(false)]
    public class SplitterPanelComponent : Control, INamingContainer
    {
        private string _clientID;
        private enumSplitterComponentType _compType;
        private string _CSSClass;
        private enumSplitterPanelType _panelType;

        public SplitterPanelComponent()
        {
            this._compType = enumSplitterComponentType.Content;
        }

        public SplitterPanelComponent(enumSplitterComponentType _splitterComponentType)
        {
            this._compType = enumSplitterComponentType.Content;
            this._compType = _splitterComponentType;
        }

        public SplitterPanelComponent(enumSplitterPanelType _splitterPanelType)
        {
            this._compType = enumSplitterComponentType.Content;
            this._panelType = _splitterPanelType;
        }

        public SplitterPanelComponent(enumSplitterComponentType _splitterComponentType, enumSplitterPanelType _splitterPanelType)
        {
            this._compType = enumSplitterComponentType.Content;
            this._compType = _splitterComponentType;
            this._panelType = _splitterPanelType;
        }

        protected override void Render(HtmlTextWriter writer)
        {
            string str = this.ControlID + "_" + this._panelType.ToString() + "_" + this._compType.ToString();
            switch (this._compType)
            {
                case enumSplitterComponentType.Header:
                case enumSplitterComponentType.Footer:
                    writer.Write("<div style=\"height:" + this.Height.ToString() + "px;\" " + this.CSSClass + " id=\"" + str + "\">");
                    break;

                case enumSplitterComponentType.Content:
                    writer.Write("<div style=\"\" " + this.CSSClass + " id=\"" + str + "\">");
                    break;
            }
            if (string.Empty == this.Url)
            {
                if (!Constants.SecondExpirationDate || !Constants.isTrial)
                {
                    base.Render(writer);
                }
            }
            else
            {
                writer.Write(".");
            }
            writer.Write("</div>");
        }

        internal string ControlID
        {
            get
            {
                return this._clientID;
            }
            set
            {
                this._clientID = value;
            }
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty)]
        public override ControlCollection Controls
        {
            get
            {
                return base.Controls;
            }
        }

        internal string CSSClass
        {
            get
            {
                return this._CSSClass;
            }
            set
            {
                this._CSSClass = value;
            }
        }

        [Category("Splitter Settings"), Bindable(true), DefaultValue(100), Description("Splitter Panel Component Height")]
        public int Height
        {
            get
            {
                object obj2 = this.ViewState["Height"];
                if (obj2 != null)
                {
                    return (int) obj2;
                }
                return 100;
            }
            set
            {
                this.ViewState["Height"] = value;
            }
        }

        [Editor(typeof(UrlEditor), typeof(UITypeEditor)), DefaultValue(""), Description("Page to load into component of the panel on page load."), Bindable(true), Category("Splitter settings")]
        public string Url
        {
            get
            {
                string str = (string) this.ViewState["Url"];
                if (str != null)
                {
                    return str;
                }
                return "";
            }
            set
            {
                this.ViewState["Url"] = value;
            }
        }
    }
}

